From c42e0260589e9664d7d71c000002814fe71fcd4f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Fri, 1 Dec 2017 08:04:31 +0100 Subject: [PATCH] snapashot: Optimize rounded clip nodes If the rounded clip node is rectilinear, we can simplify it to a normal clip node. If not, we really need to use a rounded clip node. In both cases, we can do the same check we do when collecting normal clips and avoid the clip node altogether if the child node does not get clipped anyway. This saves between 3 and 10 nodes in the widget factory, depending on what page gets rendered. --- gtk/gtksnapshot.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index c969fdece6..a5d4c3968d 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -636,7 +636,23 @@ gtk_snapshot_collect_rounded_clip (GtkSnapshot *snapshot, if (node == NULL) return NULL; - clip_node = gsk_rounded_clip_node_new (node, &state->data.rounded_clip.bounds); + /* If the given radius is 0 in all corners, we can just create a normal clip node */ + if (gsk_rounded_rect_is_rectilinear (&state->data.rounded_clip.bounds)) + { + /* ... and do the same optimization */ + if (graphene_rect_contains_rect (&state->data.rounded_clip.bounds.bounds, &node->bounds)) + return node; + + clip_node = gsk_clip_node_new (node, &state->data.rounded_clip.bounds.bounds); + } + else + { + if (gsk_rounded_rect_contains_rect (&state->data.rounded_clip.bounds, &node->bounds)) + return node; + + clip_node = gsk_rounded_clip_node_new (node, &state->data.rounded_clip.bounds); + } + if (name) gsk_render_node_set_name (clip_node, name); -- 2.30.2